//
//  YsNoteSDKNoteBookCell.m
//  YsToolsManager
//
//  Created by 宋宏康 on 2020/3/21.
//

#import "YsNoteSDKNoteBookCell.h"
#import "YsNoteSDKHelper.h"
#import <Masonry/Masonry.h>
#import <YsToolsManager/YsToolsManager.h>
#import <YYKit/YYKit.h>

@interface YsNoteSDKNoteBookCell()
/** 背景 */
@property(nonatomic, weak) UIImageView * contentImageView;
/** icon */
@property(nonatomic, weak) UIImageView * iconImageView;
/** 书名 */
@property(nonatomic, weak) UILabel * msgLabel;
@end


@implementation YsNoteSDKNoteBookCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}



- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self == nil) {
        return nil;
    }
    [self initSubviews];
    [self initClicks];
    return self;
}


- (void)initSubviews
{
    UIImageView *contentImageView = [[UIImageView alloc] init];
    contentImageView.image = [YsNoteSDKHelper imageWithName:@"img_dj"];
    self.contentImageView = contentImageView;
    [self.contentView addSubview:contentImageView];
    
    [contentImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    
    
    UIImageView *iconImageView = [[UIImageView alloc] init];
    self.iconImageView = iconImageView;
    [self.contentView addSubview:iconImageView];
    
    [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(16);
    }];

    UILabel *msgLabel = [UILabel creatLabel:@"党建笔记"
                                     textColor:UIColor.whiteColor
                                      fontSize:[UIFont systemFontOfSize:16]
                                 numberofLines:0];
    self.msgLabel = msgLabel;
    [contentImageView addSubview:msgLabel];
    
    [msgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-24);
    }];
}

- (void)initClicks
{
    
}

- (void)setNoteBookModel:(YsNoteSDKNoteBookModel *)noteBookModel
{
    if (noteBookModel.book_name.isNotBlank) {
        self.msgLabel.text = noteBookModel.book_name;
    }
    if (noteBookModel.book_icon.isNotBlank) {
        self.contentImageView.image = [YsNoteSDKHelper imageWithName:noteBookModel.book_icon];
    }
    if (noteBookModel.smallbook_icon.isNotBlank) {
        self.iconImageView.image = [YsNoteSDKHelper imageWithName:noteBookModel.smallbook_icon];
    }
}
@end
